/****************************
 * 常用基本－公共函数库
 ****************************/

(function () {

	/**
	 * 测试函数
	 **/
	exports.HELLO_ED = function () {
		return "hello ed!!!";
	};
	
	//获取日期
	exports.getTimes = function(times, state,type) {
		var nowDate = new Date();
		if(times){
			nowDate = new Date(times*1000);
		}
		if(!type){
			type = '-';
		}
		var year = nowDate.getFullYear();
		var month = nowDate.getMonth() + 1 < 10 ? "0" + (nowDate.getMonth() + 1) :
			nowDate.getMonth() + 1;
		var day = nowDate.getDate() < 10 ? "0" + nowDate.getDate() : nowDate.getDate();
		var h = nowDate.getHours() < 10 ? "0" + nowDate.getHours() : nowDate.getHours();
		var m = nowDate.getMinutes() < 10 ? "0" + nowDate.getMinutes() : nowDate.getMinutes();
		var s = nowDate.getSeconds() < 10 ? "0" + nowDate.getSeconds() : nowDate.getSeconds();
		
		if(state == 'nian') {
			var dateStr = year;
		} else if(state == 'yue') {
			var dateStr = month;
		} else if(state == 'ri') {
			var dateStr = day;
		} else if(state == 'shifen'){
			var dateStr = year + type + month + type + day + ' ' + h + ':' + m;
		} else if(state == 'cn'){
			var dateStr = year + '年' + month + '月' + day + '日';
		} else {
			var dateStr = year + type + month + type + day;
		}
		return dateStr;
	}
	
	//获取指定月份的月初月末的时间戳
	exports.getAppointBeginningEndTime = function(nianFen,yueFen) {
        var firstDate = new Date();
        if (nianFen) {
            firstDate.setFullYear(nianFen); //设置一个年份
        }
        if (yueFen) {
            firstDate.setMonth(yueFen-1); //设置一个月份
        }
        firstDate.setDate(1); //第一天
        var endDate = new Date(firstDate);
        endDate.setMonth(firstDate.getMonth()+1);
        endDate.setDate(0);

        var date = new Date(firstDate);
        var date1 = new Date(endDate);

        date.setHours(0,0,0,0);
        date1.setHours(24,0,0,0);

        firstDate = Date.parse(date) / 1000;
        endDate = Date.parse(date1) / 1000;

        var datas = {
            firstDate:firstDate,
            endDate:endDate-1
        }
        return datas;
    },

	/**
	 * 将内容生成静态json文件内容
	 **/
	exports.generateJsonFile = function(data){


	};

}).call(this);